import { createStore } from 'vuex'

interface Iitem {
  readonly id: number,
  title: string,
  status: boolean,
  time: string
}
//对list中的每一条数据进行约束

interface Istate {
  list: Iitem[],
  name: string,
}
//定义state的结构

let myState: Istate = {
  list: [],
  name: "小明"
}
//创建一个我们的state数据

export default createStore({
  state: myState,
  getters: {
  },
  mutations: {
    add(state: Istate, val: Iitem) {
      console.log(val);

      state.list.push(val)

    },
    //两个参数 state 的结构是我们定义的Istate的接口 val 的结构是Item的接口
    change(state, val: string) {
      console.log(val);


    }
  },
  actions: {
    adds({ commit }, val: Iitem) {
      commit("add", val)
    }
  },
  modules: {
  }
})
